<template>
  <div class="common-layout">
    <el-container>
      <el-header style="height: 70px;">
        <div class="top-navbar">
          <div class="logo">
            <el-icon class="logo-icon">
              <Box />
            </el-icon>
            <span>库存管理系统</span>
          </div>
          <div class="nav-right">
            <el-input placeholder="搜索..." prefix-icon="Search" size="default" class="search-input" clearable />
            <el-button type="text" class="nav-btn">
              <el-icon>
                <Bell />
              </el-icon>
            </el-button>
            <el-button type="text" class="nav-btn">
              <el-icon>
                <User />
              </el-icon>
            </el-button>
            <el-button type="text" class="nav-btn">
              <el-icon>
                <Setting />
              </el-icon>
            </el-button>
          </div>
        </div>
      </el-header>
      <el-container style="height: calc(100vh - 70px);">
        <el-aside width="280px" class="side-menu">
          <div class="menu-header">
            <el-icon>
              <Menu />
            </el-icon>
            <span>功能菜单</span>
          </div>
          <el-menu :default-active="activeMenu" class="custom-menu" @select="handleMenuSelect"
            background-color="transparent" text-color="#2c3e50" active-text-color="#409eff"  :default-openeds="openeds" router>
            <el-sub-menu index="1">
              <template #title>
                <el-icon>
                  <location />
                </el-icon>
                <span>库存管理</span>
              </template>
              <el-menu-item index="/Getinbound">入库管理</el-menu-item>
              <el-menu-item index="/Getoutbound">出库管理</el-menu-item>
              <el-menu-item index="/GetTransfer">调拨管理</el-menu-item>
               <el-menu-item index="/GetLog">操作管理</el-menu-item>
               <el-menu-item index="/GetWarehouse">仓库管理</el-menu-item>
            </el-sub-menu>

           <!-- <el-sub-menu index="2">
              <template #title>
                <el-icon><DataAnalysis /></el-icon>
                <span>仓库</span>
              </template>
              <el-menu-item index="2-1">
                <el-icon><TrendCharts /></el-icon>
                <span>库存报表</span>
              </el-menu-item>
              <el-menu-item index="2-2">
                <el-icon><PieChart /></el-icon>
                <span>销售统计</span>
              </el-menu-item>
            </el-sub-menu>
            
             <el-sub-menu index="3">
              <template #title>
                <el-icon><User /></el-icon>
                <span>用户管理</span>
              </template>
              <el-menu-item index="3-1">
                <el-icon><Avatar /></el-icon>
                <span>用户列表</span>
              </el-menu-item>
              <el-menu-item index="3-2">
                <el-icon><Lock /></el-icon>
                <span>权限管理</span>
              </el-menu-item>
            </el-sub-menu>
            
            <el-menu-item index="4">
              <el-icon><Tools /></el-icon>
              <span>系统设置</span>
            </el-menu-item> -->
          </el-menu>
        </el-aside>
        <el-main class="main-content">
          <div class="content-header">
            <el-breadcrumb separator="/">
              <el-breadcrumb-item>首页</el-breadcrumb-item>
              <el-breadcrumb-item>库存管理</el-breadcrumb-item>
            </el-breadcrumb>
          </div>
          <div class="content-body">
            <RouterView />
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import {
  Document,
  Menu,
  Location,
  Setting,
  User,
  Box,
  Bell,
} from '@element-plus/icons-vue'
import { ref } from 'vue';
import { useRouter } from 'vue-router'


const router = useRouter();
// const activeMenu = ref('1-1-1')
const activeTab = ref('企业管理')
const openeds = ref('1')
const activeMenu = ref('1')

function handleMenuSelect(index: string) {
  console.log('选中菜单:', index)
  if (index === '1-1-1') {
    router.push({ name: 'productshow' })
  }
  if (index === '1-1-2') {
    router.push({ name: 'typeshow' })
  }
}
</script>

<style scoped>
.common-layout {
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 0 24px;
  height: 70px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  position: relative;
}

.top-navbar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
}

.logo {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 600;
  z-index: 1;
}

.logo-icon {
  font-size: 24px;
  margin-right: 8px;
  color: #fff;
}

.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  z-index: 1;
}

.nav-radio-group {
  background: rgba(255,255,255,0.1);
  border-radius: 25px;
  padding: 4px;
  backdrop-filter: blur(10px);
}

.nav-radio-group .el-radio-button__inner {
  background: transparent;
  color: #fff;
  border: none;
  border-radius: 20px;
  margin: 0 2px;
  padding: 8px 16px;
  transition: all 0.3s ease;
}

.nav-radio-group .el-radio-button__inner:hover {
  background: rgba(255,255,255,0.2);
}

.nav-radio-group .is-active .el-radio-button__inner {
  background: #fff;
  color: #667eea;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.search-input {
  width: 200px;
}

.search-input :deep(.el-input__wrapper) {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.search-input :deep(.el-input__wrapper:hover) {
  border-color: rgba(255,255,255,0.4);
}

.search-input :deep(.el-input__inner) {
  color: #fff;
}

.search-input :deep(.el-input__inner::placeholder) {
  color: rgba(255,255,255,0.7);
}

.nav-btn {
  color: #fff;
  font-size: 18px;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: translateY(-2px);
}

.side-menu {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255,255,255,0.2);
  box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  overflow: hidden;
}

.menu-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.menu-header .el-icon {
  margin-right: 8px;
  font-size: 18px;
}

.custom-menu {
  border: none;
  padding: 0 16px;
}

.custom-menu .el-sub-menu__title {
  border-radius: 8px;
  margin-bottom: 4px;
  transition: all 0.3s ease;
}

.custom-menu .el-sub-menu__title:hover {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
}

.custom-menu .el-menu-item {
  border-radius: 8px;
  margin-bottom: 4px;
  transition: all 0.3s ease;
}

.custom-menu .el-menu-item:hover {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  transform: translateX(4px);
}

.custom-menu .el-menu-item.is-active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.custom-menu .el-sub-menu.is-active .el-sub-menu__title {
  color: #667eea;
  font-weight: 600;
}

.custom-menu .el-icon {
  margin-right: 8px;
  font-size: 16px;
}

.main-content {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  margin: 16px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  overflow: hidden;
}

.content-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.8);
}

.content-body {
  padding: 24px;
  min-height: calc(100vh - 200px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-center {
    display: none;
  }
  
  .side-menu {
    width: 200px !important;
  }
  
  .search-input {
    width: 150px;
  }
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-content {
  animation: fadeInUp 0.6s ease-out;
}
</style>